﻿<Window x:Class="TreeBuilder.OptionsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:ctrl="clr-namespace:Elderos.Controls;assembly=Elderos.Controls"
        xmlns:cp="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"
        Title="Options" Height="300" Width="404" 
        ResizeMode="NoResize" WindowStartupLocation="CenterOwner" WindowStyle="ToolWindow">
    <Window.Resources>
        <Style x:Key="ButtonStyle" TargetType="Button">
            <Setter Property="Width" Value="60"/>
            <Setter Property="Margin" Value="5,0,5,0"/>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="25"/>
        </Grid.RowDefinitions>
        <TabControl Background="White" BorderThickness="0,1,0,0">
            <TabItem Header="General">
                <Grid>
                    <Grid.Resources>
                        <Style x:Key="ElementStyle" TargetType="FrameworkElement">
                            <Setter Property="Margin" Value="5,0,0,0" />
                            <Setter Property="VerticalAlignment" Value="Center" />
                            <Setter Property="HorizontalAlignment" Value="Right" />
                        </Style>
                        <ToolTip x:Key="CheckUpdatesToolTip">Check updates every time TreeBuilder starts.</ToolTip>
                    </Grid.Resources>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="25"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal">
                        <CheckBox Style="{StaticResource ElementStyle}" ToolTip="{StaticResource CheckUpdatesToolTip}" Name="CheckUpdatesCheckBox" />
                        <TextBlock Style="{StaticResource ElementStyle}"
                                   ToolTip="{StaticResource CheckUpdatesToolTip}">
                            Check updates
                        </TextBlock>
                    </StackPanel>
                </Grid>
            </TabItem>
            <TabItem Header="Image">
                <Grid>
                    <Grid.Resources>
                        <Style x:Key="ElementStyle" TargetType="FrameworkElement">
                            <Setter Property="Margin" Value="5,0,0,0"/>
                            <Setter Property="VerticalAlignment" Value="Center"/>
                            <Setter Property="HorizontalAlignment" Value="Right"/>
                        </Style>
                        <Style x:Key="MarginBoxStyle" TargetType="ctrl:ValidatableTextBox" BasedOn="{StaticResource ValidatableBoxStyle}">
                            <Setter Property="Margin" Value="5,0,0,0"/>
                            <Setter Property="VerticalAlignment" Value="Center"/>
                            <Setter Property="HorizontalAlignment" Value="Right"/>
                            <Setter Property="Width" Value="28"/>
                        </Style>
                    </Grid.Resources>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="85"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock 
                        Text="Image frame:" VerticalAlignment="Center" HorizontalAlignment="Right"
                        ToolTip="Thickness (in pixels) of white frame being drawn around the tree."
                        />
                    <StackPanel Grid.Column="1" Orientation="Horizontal">
                        <TextBlock Text="Left:" Style="{StaticResource ElementStyle}"/>
                        <ctrl:ValidatableTextBox Name="FrameMarginLeftBox" Style="{StaticResource MarginBoxStyle}" 
                                                 Validate="ValidateDouble" FinalValidation="ValidateMarginSide" DefaultValue="0"/>
                        <TextBlock Text="Top:" Style="{StaticResource ElementStyle}"/>
                        <ctrl:ValidatableTextBox Name="FrameMarginTopBox" Style="{StaticResource MarginBoxStyle}" 
                                                 Validate="ValidateDouble" FinalValidation="ValidateMarginSide" DefaultValue="0"/>
                        <TextBlock Text="Right:" Style="{StaticResource ElementStyle}"/>
                        <ctrl:ValidatableTextBox Name="FrameMarginRightBox" Style="{StaticResource MarginBoxStyle}" 
                                                 Validate="ValidateDouble" FinalValidation="ValidateMarginSide" DefaultValue="0"/>
                        <TextBlock Text="Bottom:" Style="{StaticResource ElementStyle}"/>
                        <ctrl:ValidatableTextBox Name="FrameMarginBottomBox" Style="{StaticResource MarginBoxStyle}" 
                                                 Validate="ValidateDouble" FinalValidation="ValidateMarginSide" DefaultValue="0"/>
                    </StackPanel>
                    <TextBlock 
                        Text="Resolution:" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center"
                        ToolTip="Count of pixels being used for one square inch of the image. Minimal recommended value is 220."
                        />
                    <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
                        <TextBlock Text="DpiX:" Style="{StaticResource ElementStyle}"/>
                        <ctrl:ValidatableTextBox Name="ImageDpiXBox" Style="{StaticResource MarginBoxStyle}" 
                                                 Validate="ValidateDouble" FinalValidation="ValidateDpi" DefaultValue="220"/>
                        <TextBlock Text="DpiY:" Style="{StaticResource ElementStyle}"/>
                        <ctrl:ValidatableTextBox Name="ImageDpiYBox" Style="{StaticResource MarginBoxStyle}" 
                                                 Validate="ValidateDouble" FinalValidation="ValidateDpi" DefaultValue="220"/>
                    </StackPanel>
                </Grid>
            </TabItem>
            <TabItem Header="Nodes">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="85"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Font:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"/>
                    <Button Name="NodeFontButton"  Style="{StaticResource ButtonStyle}" Grid.Column="1" HorizontalAlignment="Left" Content="..."
                            Click="NodeFontButton_Click"
                            />
                    <RichTextBox Grid.Row="4" Grid.ColumnSpan="2" IsReadOnly="True" VerticalScrollBarVisibility="Auto">
                        <RichTextBox.Document>
                            <FlowDocument>
                                <Paragraph Name="NodeFontSample"
                                    xml:space="preserve"
                                    >The quick brown fox jumps over the lazy dog.
Эх, пиши: зять съел щи, яйцо, чан брюквы. Ждём фигу!
                                </Paragraph>
                            </FlowDocument>
                        </RichTextBox.Document>
                    </RichTextBox>
                </Grid>
            </TabItem>
            <TabItem Header="Frames">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="85"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Color:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"/>
                    <TextBlock Text="Thickness:" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"/>
                    <TextBlock 
                        Text="Dashes:" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"
                        ToolTip="Array of numbers separated by space. See help page &quot;Binders&quot; for more info."
                        />
                    <cp:ColorPicker Name="FrameColorPicker" Grid.Column="1" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"/>
                    <ctrl:ValidatableTextBox Style="{StaticResource ValidatableBoxStyle}" Name="FrameThicknessBox" Text="1" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" 
                                             Validate="ValidateDouble" FinalValidation="ValidateThickness" DefaultValue="1"/>
                    <ctrl:ValidatableTextBox Style="{StaticResource ValidatableBoxStyle}" Name="FrameDashesBox" Text="" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" 
                                             Validate="ValidateDoubleCollection" FinalValidation="ParseDoubleCollection" DefaultValue=""/>
                </Grid>
            </TabItem>
            <TabItem Header="Lines">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="85"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Color:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"/>
                    <TextBlock Text="Thickness:" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"/>
                    <TextBlock 
                        Text="Dashes:" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"
                        ToolTip="Array of numbers separated by space. See help page &quot;Binders&quot; for more info."
                        />
                    <cp:ColorPicker Name="LineColorPicker" Grid.Column="1" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"/>
                    <ctrl:ValidatableTextBox Style="{StaticResource ValidatableBoxStyle}" Name="LineThicknessBox" Text="1" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" 
                                             Validate="ValidateDouble" FinalValidation="ValidateThickness" DefaultValue="1"/>
                    <ctrl:ValidatableTextBox Style="{StaticResource ValidatableBoxStyle}" Name="LineDashesBox" Text="" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" 
                                             Validate="ValidateDoubleCollection" FinalValidation="ParseDoubleCollection" DefaultValue=""/>
                </Grid>
            </TabItem>
            <TabItem Header="Arrows">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="85"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Color:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"/>
                    <TextBlock Text="Thickness:" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"/>
                    <TextBlock Text="Dashes:" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"
                               ToolTip="Array of numbers separated by space. See help page &quot;Binders&quot; for more info."
                               />
                    <TextBlock Text="Vertical offset:" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"
                               ToolTip="Minimal number of pixels being drawn between a node and arrow's arc. See help page &quot;Binders&quot; for more info."/>
                    <cp:ColorPicker Name="ArrowColorPicker" Grid.Column="1" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"/>
                    <ctrl:ValidatableTextBox Style="{StaticResource ValidatableBoxStyle}" Name="ArrowThicknessBox" Text="1" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" 
                                             Validate="ValidateDouble" FinalValidation="ValidateThickness" DefaultValue="1"/>
                    <ctrl:ValidatableTextBox Style="{StaticResource ValidatableBoxStyle}" Name="ArrowDashesBox" Text="" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" 
                                             Validate="ValidateDoubleCollection" FinalValidation="ParseDoubleCollection" DefaultValue=""/>
                    <ctrl:ValidatableTextBox Style="{StaticResource ValidatableBoxStyle}" Name="ArrowVerticalOffsetBox" Text="" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" 
                                             Validate="ValidateDouble" FinalValidation="ValidateVerticalOffset" DefaultValue="0"/>
                </Grid>
            </TabItem>
            <TabItem Header="Triangles">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="85"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Color:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"/>
                    <TextBlock Text="Thickness:" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"/>
                    <TextBlock Text="Dashes:" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"
                               ToolTip="Array of numbers separated by space. See help page &quot;Binders&quot; for more info."
                               />
                    <cp:ColorPicker Name="TriangleColorPicker" Grid.Column="1" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"/>
                    <ctrl:ValidatableTextBox Style="{StaticResource ValidatableBoxStyle}" Name="TriangleThicknessBox" Text="1" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" 
                                             Validate="ValidateDouble" FinalValidation="ValidateThickness" DefaultValue="1"/>
                    <ctrl:ValidatableTextBox Style="{StaticResource ValidatableBoxStyle}" Name="TriangleDashesBox" Text="" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" 
                                             Validate="ValidateDoubleCollection" FinalValidation="ParseDoubleCollection" DefaultValue=""/>
                </Grid>
            </TabItem>
            <TabItem Header="Indexes">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="85"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Upper index:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"/>
                    <Button Name="UpperIndexFontButton"  Style="{StaticResource ButtonStyle}" Grid.Column="1" HorizontalAlignment="Left" Content="Font..."
                            Click="UpperIndexFontButton_Click"
                            />
                    <TextBlock Text="Lower index:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0" Grid.Row="1"/>
                    <Button Name="LowerIndexFontButton"  Style="{StaticResource ButtonStyle}" Grid.Column="1" HorizontalAlignment="Left" Content="Font..."
                            Click="LowerIndexFontButton_Click" Grid.Row="1"
                            />
                    <RichTextBox Grid.Row="4" Grid.ColumnSpan="2" IsReadOnly="True" VerticalScrollBarVisibility="Auto">
                        <RichTextBox.Document>
                            <FlowDocument>
                                <Paragraph Name="UpperIndexSample"
                                    xml:space="preserve"
                                    >The quick brown fox jumps over the lazy dog.
Эх, пиши: зять съел щи, яйцо, чан брюквы. Ждём фигу!
                                </Paragraph>
                                <Paragraph Name="LowerIndexSample"
                                    xml:space="preserve"
                                    >The quick brown fox jumps over the lazy dog.
Эх, пиши: зять съел щи, яйцо, чан брюквы. Ждём фигу!
                                </Paragraph>
                            </FlowDocument>
                        </RichTextBox.Document>
                    </RichTextBox>
                </Grid>
            </TabItem>
        </TabControl>
        <StackPanel Grid.Row="1"
                    HorizontalAlignment="Right"
                    Orientation="Horizontal">
            <Button Name="OkButton"
                    Style="{StaticResource ButtonStyle}"
                    IsDefault="True"
                    Click="OkButton_Click">Ok</Button>
            <Button Name="CancelButton"
                    Style="{StaticResource ButtonStyle}"
                    IsCancel="True">Cancel</Button>
            <Button Name="ApplyButton"
                    Style="{StaticResource ButtonStyle}"
                    Click="ApplyButton_Click">Apply</Button>
        </StackPanel>
    </Grid>
</Window>
